﻿using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProDeletor
{
    class EventLogWriter
    {
        string applicationName = "ProDeletor";
        EventLog eventLog;

        public EventLogWriter()
        {
            bool justCreated=false;
            if (!System.Diagnostics.EventLog.SourceExists(applicationName))
            {
                System.Diagnostics.EventLog.CreateEventSource(applicationName, "Application");
                justCreated = true;
            }

            eventLog = new EventLog();
            if (justCreated)
                eventLog.WriteEntry("New Eventsource 'ProDeletor' created", EventLogEntryType.Information);
        }

        public void writeLogEntry(string description, EventLogEntryType level)
        {
            eventLog.Source = applicationName;
            eventLog.WriteEntry(description, level);
        }
    }
}
